package com.controller;

import com.common.Result;
import com.entity.Collection;
import com.service.CollectionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * User的路由接口服务
 * 
 * @author 
 *
 */
@RestController
@RequestMapping("pcApi")
public class CollectionController {

	/** UserService服务 */
	@Autowired
	private CollectionService collectionService;

	/**
	 * 通过id查询User数据的方法
	 * @param id
	 * @return
	 */
	@ResponseBody
	@GetMapping(value = "/collection/{id}", produces = {"application/json;charset=UTF-8"})
	public Collection findOne(@PathVariable(name="id") int id) {
		return collectionService.findOne(id);
	}

	/**
	 * 添加收藏
	 * @param bean
	 * @return
	 */
	@ResponseBody
	@PostMapping(value = "/collection/create", produces = {"application/json;charset=UTF-8"})
	public Result create(@RequestBody Collection bean){
		return collectionService.create(bean);
	}

	/**
	 * 根据用户id分页查询收藏的文章
	 * @param bean
	 * @return
	 */
	@ResponseBody
	@PostMapping(value = "/collection/indexByUserId", produces = {"application/json;charset=UTF-8"})
	public Result indexByUserId(@RequestBody Collection bean){
		return collectionService.indexByUserId(bean);
	}



}
